home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / pctchnqs / 1990 / number6 / generic2.c < prev    next >
Text File  |  1990-12-19  |  2KB  |  52 lines

  1. /****************************************************************************
  2.  
  3.     FUNCTION: Panic(HWND, unsigned, WORD, LONG)
  4.  
  5.     PURPOSE:  Processes messages for "Panic" dialog box
  6.  
  7.     MESSAGES:
  8.  
  9.         WM_INITDIALOG - initialize dialog box
  10.         WM_COMMAND    - Input received
  11.  
  12.     COMMENTS:
  13.  
  14.         No initialization is needed for this particular dialog box, but TRUE
  15.         must be returned to Windows.
  16.  
  17.         Wait for user to click on "Panic" button. When this happens, add
  18.         the word "again" to the empty static text control in the dialog box.
  19.         When a second click is received, close the dialog.
  20.  
  21. ****************************************************************************/
  22.  
  23. BOOL FAR PASCAL Panic(hDlg, message, wParam, lParam)
  24. HWND hDlg;                                /* window handle of the dialog box */
  25. unsigned message;                         /* type of message                 */
  26. WORD wParam;                              /* message-specific information    */
  27. LONG lParam;
  28. {
  29. static BOOL bHitOnce;                     /* Has panic button been hit once? */
  30. static char far szAgain[] = "again!";     /* Text to add to dialog box */
  31.     switch (message) {
  32.         case WM_INITDIALOG:                /* message: initialize dialog box */
  33.             bHitOnce = FALSE;              /* Panic button not hit yet */
  34.             return (TRUE);
  35.         case WM_COMMAND:                   /* message: received a command */
  36.             switch (wParam) {                 /* Which command? */
  37.                 case IDOK:                    /* Panic button hit */
  38.                     if (!bHitOnce) {          /* If first push, change msg */
  39.                         bHitOnce = TRUE;
  40.                         SetDlgItemText(hDlg,IDC_AGAIN,szAgain);
  41.                         MessageBeep(0);
  42.                         return (TRUE);
  43.                     }                         /* Otherwise, fall through */
  44.                 case IDCANCEL:
  45.                     EndDialog(hDlg, TRUE);    /* Exits the dialog box        */
  46.                     return (TRUE);
  47.             }
  48.             break;
  49.     }
  50.     return (FALSE);                           /* Didn't process a message    */
  51. }
  52.